package org.garbagecan.springstudy.dao.hibernate.service;

import org.garbagecan.springstudy.dao.hibernate.User;
import org.garbagecan.springstudy.dao.hibernate.dao.BaseDao;

import java.util.List;

public class UserServiceImpl implements UserService {
	
	private BaseDao<User, String> userDao;
	
	public User findById(String id) {
		return this.userDao.get(id);
	}

	public List<User> list() {
		return this.userDao.loadAll();
	}

	public void add(User user) {
		this.userDao.save(user);
	}

	public void update(User user) {
		this.userDao.update(user);
	}

	public void delete(User user) {
		this.userDao.delete(user);
	}

	public void delete(String id) {
		this.userDao.deleteByKey(id);
	}

	public void setUserDao(BaseDao userDao) {
		this.userDao = userDao;
	}
}
